package com.etlmaster.executor.trans.core;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 转换规则
 * @author Wugf
 * @date 2017-03-08
 */
public class Rule implements Serializable{
	private Map<String, Object> funcMaps;
	private String sourceTable;
	private String sourceCol;
	private String targetTable;
	private String targetCol;
	private String ruleId;

	public Rule(String ruleId, String sourceTable, String sourceCol,
			String targetTable, String targetCol) {
		this.ruleId = ruleId;
		this.sourceTable = sourceTable.toUpperCase();
		this.sourceCol = sourceCol.toUpperCase();
		this.targetTable = targetTable.toUpperCase();
		this.targetCol = targetCol.toUpperCase();
	}

	public String getRuleId() {
		return ruleId;
	}

	public void setRuleId(String ruleId) {
		this.ruleId = ruleId;
	}

	public String getTargetCol() {
		return targetCol;
	}

	public void setTargetCol(String targetCol) {
		this.targetCol = targetCol;
	}

	public String getTargetTable() {
		return targetTable;
	}

	public void setTargetTable(String targetTable) {
		this.targetTable = targetTable;
	}

	public String getSourceCol() {
		return sourceCol;
	}

	public void setSourceCol(String sourceCol) {
		this.sourceCol = sourceCol;
	}

	public String getSourceTable() {
		return sourceTable;
	}

	public void setSourceTable(String sourceTable) {
		this.sourceTable = sourceTable;
	}

	public void setFuncMap(Map<String, Object> map, String funcType,
			String paraType) {

		List<Map<String, Object>> paramList = (List<Map<String, Object>>) map
				.get(paraType);
		for (Map<String, Object> param : paramList) {
			Map<String,Map<String,Object>> changeMap=(Map<String, Map<String, Object>>) getFuncMaps().get(funcType);
			if(changeMap==null){
				changeMap=new HashMap<String,Map<String,Object>>();
			}
			changeMap.put((String) param.get("funCode"), (Map<String, Object>) param.get("param"));
			getFuncMaps().put(funcType,changeMap);
		}

	}

	public Map<String, Object> getFuncMaps() {
		return funcMaps;
	}

	public void setFuncMaps(Map<String, Object> funcMaps) {
		this.funcMaps = funcMaps;
	}


}
